package com.ruoyi.web.dorm.service.impl;

import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.web.dorm.entity.RepairRegistrationEntity;
import com.ruoyi.web.dorm.mapper.RepairMapper;
import com.ruoyi.web.dorm.service.RepairService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class RepairServiceImpl implements RepairService {
    @Autowired
    private RepairMapper repairMapper;

    // 查询报修列表
    @Override
    public List<RepairRegistrationEntity> getRepairList(RepairRegistrationEntity repairRegistrationEntity) {
        return repairMapper.getRepairList(repairRegistrationEntity);
    }
    // 添加报修列表
    @Override
    public int addRepairList(RepairRegistrationEntity repairRegistrationEntity) {
        String username = SecurityUtils.getLoginUser().getUsername(); //获取修改人的名字 添加进去
        repairRegistrationEntity.setCreateBy(username);
        return repairMapper.addRepairList(repairRegistrationEntity);
    }

    @Override
    public int updateRepair(RepairRegistrationEntity repairRegistrationEntity) {
        String username = SecurityUtils.getLoginUser().getUsername(); //获取修改人的名字 添加进去
        repairRegistrationEntity.setUpdateBy(username);
        return repairMapper.updateStudent(repairRegistrationEntity);
    }

    @Override
    public int delRepair(Long id) {
        return repairMapper.delRepair(id);
    }
}
